package com.Object;
/*建议所有子类覆盖即重写to String()方法*/
public class ObjectDemo {
    public static void main(String[] args) {
        Student s = new Student();
        s.setName("加菲猫");
        s.setAge(5);
        System.out.println(s);//com.Object.Student@776ec8df
        System.out.println(s.toString());//com.Object.Student@776ec8df

        //toString()默认输出com.Object.Student@776ec8df
        //toString()重写后输出Student{name='加菲猫', age=5}

    }
}
    /*public void println(Object x) {
        String s = String.valueOf(x);
        if (getClass() == PrintStream.class) {
            writeln(String.valueOf(s));
        } else {
            synchronized (this) {
                print(s);
                newLine();
            }
        }
    }*/
   /* public static String valueOf(Object obj) {
        return (obj == null) ? "null" : obj.toString();
    }
    public String toString() {
        return getClass().getName() + "@" + Integer.toHexString(hashCode());
    }*/

